#!/usr/bin/env python

import sys
import socket
import random
import struct

from scapy.all import *
from scapy.all import sendp, send, get_if_list, get_if_hwaddr, hexdump
from scapy.all import Packet
from scapy.layers.inet import ARP
from scapy.layers.l2 import Ether
import time


def get_if():
    ifs = get_if_list()
    iface = None
    for i in get_if_list():
        if "enp27s0" in i:
            iface = i
            break;
    if not iface:
        print("cannot find eth0")
        exit(1)
    return iface


def main():
    print('sending_message')
    iface = get_if()
    # print('Ether_done')
    ether = Ether(src=get_if_hwaddr(iface), dst='f8:0f:41:f6:d8:6b', type=0x0806)
    arp = ARP(op=3, hwsrc='f8:0f:41:f6:d8:6b', psrc='172.18.100.2')

    pkt = ether / arp

    pkt.show2()
    # print(int(round(current_time * 1000)))

    sendp(pkt, iface=iface, verbose=False)

    return pkt


if __name__ == '__main__':
    main()
